﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
        xmlns:Memento="clr-namespace:MementoClient" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        mc:Ignorable="d" 
        x:Class="MementoClient.MainWindow"
        Title="Memento"
        Width="578"
        DataContext="{Binding Source={StaticResource Locator}, Path=MainViewModel}"
        >
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVis" />
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="Escape" Command="{Binding EscapeKeyPress}"/>
    </Window.InputBindings>
    <Canvas>
        <ListBox x:Name="taskList" Width="550" Canvas.Top="50" Canvas.Left="10" Panel.ZIndex="1" SelectedItem="{Binding SelectedTask}" ItemsSource="{Binding FilteredTasksForUser}" Visibility="{Binding IsFilteredTaskListVisible, Converter={StaticResource boolToVis}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <DockPanel HorizontalAlignment="Stretch">
                        <Label DockPanel.Dock="Top" Content="{Binding TaskName}" />
                        <Label DockPanel.Dock="Left" Content="{Binding ProjectName}" Foreground="Orange"/>
                        <Label DockPanel.Dock="Right" Content="{Binding AccountName}"/>
                        <Label DockPanel.Dock="Bottom" Content=""></Label>
                    </DockPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDoubleClick" >
                    <i:InvokeCommandAction Command="{Binding TaskSelected}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ListBox>
        <DockPanel>
            <StatusBar DockPanel.Dock="Bottom" x:Name="statusBar" HorizontalAlignment="Stretch">
                <ListBox ItemsSource="{Binding Path=Messages}"/>
                <Separator/>
                <ProgressBar IsIndeterminate="{Binding IsBusy}" Visibility="{Binding IsBusy, Converter={StaticResource boolToVis}}" />
            </StatusBar>
            <StackPanel DockPanel.Dock="Left" x:Name="containerStackPanel" Margin="10,10,10,0" HorizontalAlignment="Left">
                <Label HorizontalAlignment="Right" Foreground="Gold" Content="{Binding Path=TasksForUser.Count}" ContentStringFormat="{}{0} tasks available"></Label>
                <TextBox x:Name="taskSearchBox" Width="550" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"  >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="TextChanged" >
                            <i:InvokeCommandAction Command="{Binding SearchTextChange}" />
                        </i:EventTrigger>
                        <i:EventTrigger EventName="GotFocus" >
                            <i:InvokeCommandAction Command="{Binding SearchTextFocus}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,5" >
                    <Label x:Name="lblSelectedDate" Width="100" Content="{Binding Path=SelectedDate}" ContentStringFormat="{}{0:ddd dd MMM yyyy}"/>
                    <DatePicker x:Name="workDate" Width="30" Margin="10,0,10,0" FirstDayOfWeek="Monday" BorderThickness="0" SelectedDate="{Binding SelectedDate}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectedDateChanged" >
                                <i:InvokeCommandAction Command="{Binding SelectedDateChange}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </DatePicker>
                    <TextBox x:Name="txtHours" Text="hrs" Margin="5,0,0,0"/>
                    <TextBox x:Name="txtMinutes" Text="mins" Margin="5,0,0,0"/>
                    <Button x:Name="btnCreateNewWorkLog" Command="{Binding CreateNewWorklog}" Margin="5,0,0,0">
                        <Image Source="Assets/tick.png" Height="24" Width="24"></Image>
                    </Button>
                </StackPanel>
                <ListBox SelectedItem="{Binding SelectedWorklog}" ItemsSource="{Binding WorkLogs}" Height="413">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Label Content="{Binding DisplayString}" />
                                <Button Command="{Binding EditThisWorklog}" >
                                    <Image Source="Assets/edit.png" Height="24" Width="24"></Image>
                                </Button>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
        </DockPanel>
    </Canvas>
</Window>
